package LocalStorage

import (
	"KumquatDrivesServices/utils"
	"fmt"
	"path/filepath"
)

func (LocalEngine) GenerateThumbnail(srcPath string) (string, error) {
	outPath := filepath.Join(filepath.Dir(srcPath), "cover", utils.GetBaseNameWithoutExt(srcPath)+".jpg")
	if !utils.PathExists(srcPath) {
		return "", fmt.Errorf("The path does not exist: %s", srcPath)
	}
	if err := utils.CreatePath(outPath); err != nil {
		return "", err
	}
	if err := utils.CompressSingleImage(srcPath, outPath, 200); err != nil {
		return "", err
	}
	return outPath, nil
}
